package cn.llyong.rpc.client.loadbalance;

import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description: 轮寻
 * @author: lvyong
 * @date: 2020年07月23日 18:40
 */
@Component
public class RoundLoadBalance implements LoadBalance {

    private volatile static Integer pos = 0;

    @Override
    public synchronized String chose(List<String> serverList) {
        if (pos >= serverList.size()) {
            pos = 0;
        }
        return serverList.get(pos++);
    }
}
